<template>
  <a-modal v-model:visible="visible" title="编辑阈值" :footer="null">
    <div class="py-8">
      <this-form @finished="finished" ref="formRef" />
    </div>
  </a-modal>
</template>
<script lang="ts">
import { defineComponent, ref, nextTick } from 'vue';
import thisForm from './form.vue';

export default defineComponent({
  components: { thisForm },
  setup(props, { emit }) {
    const visible = ref<boolean>(false);
    const formRef = ref<any>();
    let hid = 0;

    const open = (row = null) => {
      hid = row.gatherDeviceId;
      visible.value = true;

      nextTick(() => {
        formRef.value.setForm(row);
      });
    };

    const finished = (event) => {
      visible.value = false;
      emit('finished', hid);
    };

    return {
      visible,
      finished,
      open,
      formRef,
    };
  },
});
</script>
